package com.example.android;

import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class ApplicationContext extends Application {

    public static String versionName;
    public static AppDB appDB;
    public static String username;
    
    @Override
    public void onCreate() {
        versionName = getVersionName();
        appDB = new AppDB(this);
        super.onCreate();
    }
    
    private String getVersionName(){
        PackageManager pm = getPackageManager();
        try {
            PackageInfo pi = pm.getPackageInfo(getPackageName(), 0);
            return pi.versionName;
        } catch (NameNotFoundException e) {
            return "";
        }
    }
}
